{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "f0673bc0c53d4994ad197b2b1c86428b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Output()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import k3d\n",
    "\n",
    "vertices = [\n",
    "    -10.0, -15.0, 0.0,\n",
    "    -10.0,   5.0, 0.0,\n",
    "     10.0,   5.0, 0.0,\n",
    "    -10.0, -15.0, 0.0,\n",
    "     10.0, -15.0, 0.0,\n",
    "    -10.0,   5.0, 0.0,\n",
    "      0.0,  15.0, 0.0,\n",
    "     10.0,   5.0, 0.0,\n",
    "     10.0, -15.0, 0.0\n",
    "]\n",
    "\n",
    "colors = [\n",
    "    0xff,\n",
    "    0xffff,\n",
    "    0xff00ff,\n",
    "    0x00ffff,\n",
    "    0xffff00,\n",
    "    0xff00,\n",
    "    0xff0000,\n",
    "    0xff00ff,\n",
    "    0xffffff\n",
    "]\n",
    "\n",
    "line = k3d.line(vertices, colors=colors, width=0.5)\n",
    "\n",
    "plot = k3d.plot(antialias=True)\n",
    "plot += line\n",
    "plot.display()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "line.shader = \"mesh\";"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "line.radial_segments = 5;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "line.visible = False\n",
    "plot.camera_reset()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "line.visible = True\n",
    "plot.camera_reset()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import k3d\n",
    "import math\n",
    "import numpy as np\n",
    "\n",
    "plot = k3d.plot(antialias=True)\n",
    "\n",
    "for i in range(10):\n",
    "    vertices = []\n",
    "    s = []\n",
    "    \n",
    "    for fi in np.arange(0,2*math.pi, 0.01):\n",
    "        vertices.append([            \n",
    "            math.sin(fi*4+i), \n",
    "            math.cos(fi*7+i), \n",
    "            math.cos(fi*3) + fi * 1.5\n",
    "        ])\n",
    "        s.append(math.sin(fi*i))\n",
    "    \n",
    "    plot += k3d.line(vertices, attribute=s, color_range=[-1,1], color_map=k3d.basic_color_maps.Jet, width=0.03)\n",
    "\n",
    "plot.display()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for obj in plot.objects:\n",
    "    obj.shader = \"mesh\"\n",
    "    obj.width = 0.05"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "for obj in plot.objects:\n",
    "    obj.shader = \"thick\"\n",
    "    obj.width = 0.1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
